翻訳と辞書
Words near each other
・ Polygamy in Yemen
・ Polygamy in Zambia
・ Polygamy in Zimbabwe
・ Polygamy, USA
・ Polygar Wars
・ Polygasropteryx
・ Polygene
・ Polygenesis
・ Polygenesis (linguistics)
・ Polygenetic volcanic field
・ Polygenis gwyni
・ Polygenism
・ Polygireulima
・ Polygireulima amblytera
・ Polyglot (book)
Polyglot (computing)
・ Polyglot (disambiguation)
・ Polyglot (webzine)
・ Polyglot markup
・ Polyglot Persistence
・ Polyglotism
・ Polyglotta Africana
・ Polyglutamation
・ Polyglutamic acid
・ Polyglutamine tract
・ Polyglutamylation
・ Polyglycerol polyricinoleate
・ Polyglycolide
・ Polyglycylation
・ Polyglyphanodontia


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Polyglot (computing) : ウィキペディア英語版
In computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it.Generally polyglots are written in a combination of C (which allows redefinition of tokens with a preprocessor) and a scripting language such as Lisp, Perl or sh.Polyglot markup is similar, but about markup language context.== Methods ==The two most commonly used techniques for constructing a polyglot program are to make liberal use of languages that use different characters for comments and to redefine various tokens as others in different languages. Often good use is made of syntax quirks. These are demonstrated in this public domain polyglot written in ANSI C, PHP and bash:

In computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it.
Generally polyglots are written in a combination of C (which allows redefinition of tokens with a preprocessor) and a scripting language such as Lisp, Perl or sh.
Polyglot markup is similar, but about markup language context.
== Methods ==

The two most commonly used techniques for constructing a polyglot program are to make liberal use of languages that use different characters for comments and to redefine various tokens as others in different languages. Often good use is made of syntax quirks. These are demonstrated in this public domain polyglot written in ANSI C, PHP and bash:
#define a /
*
# echo "\010Hello, world!\n";// 2> /dev/null > /dev/null \ ;
// 2> /dev/null; x=a;
$x=5; // 2> /dev/null \ ;
if (($x))
// 2> /dev/null; then
return 0;
// 2> /dev/null; fi
#define e ?>
#define b
*/
#include
#define main() int main(void)
#define printf printf(
#define true )
#define function
function main()

#define c /
*
main
#
*/
Note the following:
*A hash sign marks a preprocessor statement in C, but is a comment in both bash and PHP.
*"//" is a comment in both PHP and C and the root directory in bash.
*Shell redirection is used to eliminate undesirable outputs.
*Even on commented out lines, the "<?php" and "?>" PHP indicators still have effect.
*The statement "function main()" is valid in both PHP and bash; C #defines are used to convert it into "int main(void)" at compile time.
*Comment indicators can be combined to perform various operations.
*"if (($x))" is a valid statement in both bash and PHP.
*printf is a bash shell builtin which is identical to the C printf except for its omission of brackets (which the C preprocessor adds if this is compiled with a C compiler).
*The final three lines are only used by bash, to call the main function. In PHP the main function is defined but not called and in C there is no need to explicitly call the main function.
Some less-common languages also offer possibilities to create Polyglot code. Here is a small sample, written simultaneously in SNOBOL4, Win32Forth, PureBasicv4.x, and REBOL:

*BUFFER : A.A ; .( Hello, world !) @ To Including?
Macro SkipThis; OUTPUT = Char(10) "Hello, World !"
;OneKeyInput Input('Char', 1, '()') ; Char
End; SNOBOL4 + PureBASIC + Win32Forth + REBOL = <3
EndMacro: OpenConsole() : PrintN("Hello, world !")
Repeat : Until Inkey() : Macro SomeDummyMacroHere
REBOL (Title: "'Hello, World !' in 4 languages"
CopyLeft: "Developed in 2010 by Society"
) Print
"Hello, world !" EndMacro: func Input set-modes
system/ports/input (false ) NOP:: EndMacro
; Wishing to refine it with new language ? Go on !
The term is sometimes applied to programs that are valid in more than one language, but do not strictly perform the same function in each. One use for this form is a file that runs as a DOS batch file, then re-runs itself in Perl:
@rem = ' --PERL--
@echo off
perl "%~dpnx0" %
*
goto endofperl
@rem ';
#!perl
print "Hello, world!\n";
__END__
:endofperl
This allows creating Perl scripts that can be run on DOS systems with minimal effort.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「In computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it.Generally polyglots are written in a combination of C (which allows redefinition of tokens with a preprocessor) and a scripting language such as Lisp, Perl or sh.Polyglot markup is similar, but about markup language context.== Methods ==The two most commonly used techniques for constructing a polyglot program are to make liberal use of languages that use different characters for comments and to redefine various tokens as others in different languages. Often good use is made of syntax quirks. These are demonstrated in this public domain polyglot written in ANSI C, PHP and bash: 」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.